﻿using System.Windows;
using System.Windows.Controls;

namespace SL8.SL.Controls
{
    public class TransitionFrame : Frame
    {
        private ContentPresenter CurrentContentPresentationSite;
        private ContentPresenter PreviousContentPresentationSite;

        public static readonly DependencyProperty TransitionDirectionProperty = DependencyProperty.Register("TransitionDirection", typeof(FlowDirection), typeof(TransitionFrame), new PropertyMetadata(FlowDirection.RightToLeft));

        public FlowDirection TransitionDirection
        {
            get
            {
                return (FlowDirection)base.GetValue(TransitionFrame.TransitionDirectionProperty);
            }

            set
            {
                base.SetValue(TransitionFrame.TransitionDirectionProperty, value);
            }
        }

        public TransitionFrame()
        {
            DefaultStyleKey = typeof(TransitionFrame);
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            return;
            this.PreviousContentPresentationSite = GetTemplateChild("PreviousContentPresentationSite") as ContentPresenter;
            this.CurrentContentPresentationSite = GetTemplateChild("CurrentContentPresentationSite") as ContentPresenter;

            if (this.CurrentContentPresentationSite != null)
            {
                this.CurrentContentPresentationSite.Content = Content;
            }
        }

        protected override void OnContentChanged(object oldContent, object newContent)
        {
            base.OnContentChanged(oldContent, newContent);

            return;
            if ((this.CurrentContentPresentationSite != null) && (this.PreviousContentPresentationSite != null))
            {
                this.CurrentContentPresentationSite.Content = newContent;
                this.PreviousContentPresentationSite.Content = oldContent;

                VisualStateManager.GoToState(this, "Normal", false);

                if (this.TransitionDirection == System.Windows.FlowDirection.LeftToRight)
                {
                    VisualStateManager.GoToState(this, "TransitionLeftToRight", true);
                }
                else
                {
                    VisualStateManager.GoToState(this, "TransitionRightToLeft", true);
                }
            }
        }
    }
}